import { http } from '@/utils/http';
import type { ChatConfig, ChatGptRO, GptSessionVO, MessageContentDto } from '@/types/chatgpt';

export enum ChatType {
    THREE_CHAT
}

export const sendMessages = (data: ChatGptRO) => {
    return http({
        url: '/chat/saveMessages',
        method: 'POST',
        data
    });
};

/**
 * 返回sessionId
 * @param data
 */
export const createSession = (data: ChatGptRO) => {
    return http<string>({
        url: '/gptSession/create',
        method: 'POST',
        data
    });
};

/**
 * 返回会话列表
 */
export const getSessionList = () => {
    return http<GptSessionVO[]>({
        url: '/gptSession/list',
        method: 'GET'
    });
};

export const saveContent = (sessionId: string, data: ChatGptRO) => {
    return http({
        url: '/gptSessionContent/save?sessionId=' + sessionId,
        method: 'POST',
        data
    });
};

export const getContent = (data: string) => {
    return http<MessageContentDto[]>({
        url: '/gptSession/contentList?sessionId=' + data,
        method: 'GET'
    });
};

export const delSession = (sessionId: string) => {
    return http({
        url: '/gptSession/del?sessionId=' + sessionId,
        method: 'POST'
    });
};

export const getFrequency = () => {
    return http<number>({
        url: '/chat/frequency',
        method: 'GET'
    });
};

export const getUseNum = () => {
    return http<number>({
        url: '/gptSessionContent/useNum',
        method: 'GET'
    });
};

export const getHistoryNum = () => {
    return http<number>({
        url: '/gptSession/historyNum',
        method: 'GET'
    });
};

export const getChatConfig = () => {
    return http<ChatConfig>({
        url: '/chat/chatConfig',
        method: 'GET'
    });
};

export const saveChatConfig = (data: ChatConfig) => {
    return http({
        url: '/chat/chatConfig',
        method: 'POST',
        data
    });
};

export const getShowWxMiniApp = () => {
    return http<boolean>({
        url: '/chat/showMiniApp',
        method: 'GET'
    });
};
